const logger = require("../utils/log4js");
const { wsSend } = require('../utils/utils')

module.exports = (ws, params, online) => {
    const { userId, msg } = params
    logger.info('appendFriend', online.map(it => it.userInfo.name))
    let _online = online.find(item => item.userInfo._id === userId)
    if (_online) {
        // 在线
        wsSend(_online.ws, '/appendFriend', {
            code: 1,
            data: msg
        })
    }
    wsSend(ws, '/appendFriend', {
        code: 0
    })
}